import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-09-29
 * Time: 20:02
 */
public class Test {
    static class TreeNode{
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val){
            this.val=val;
        }
    }
    public int compare (String version1, String version2) {
        int i=0;
        int j=0;
        int l1=version1.length();
        int l2=version2.length();
        while(i < l1 || j < l2){//为什么这里是|| 因为其中一个字符串比较完不妨碍它后面的num为0；一样可以参与num1和num2的比较
            int num1=0;//
            while(i < l1 && version1.charAt(i)!='.'){
                num1=num1 * 10 + (version1.charAt(i) - '0');
                i++;
            }
            i++;
            int num2=0;
            while(j < l2 && version2.charAt(j)!='.'){
                num2=num2 * 10 + (version2.charAt(j) - '0');
                j++;
            }
            j++;
            if(num1 > num2){
                return 1;
            } else if (num1 < num2) {
                return -1;
            }
        }
        return 0;//比完出来如果依旧没有在上面return 就说明版本号相等
    }

    public void preOrder(TreeNode root){
        if(root == null){
            return;
        }
        System.out.print(root.val+" ");
        preOrder(root.left);
        preOrder(root.right);
    }

    public void preOrderNor(TreeNode root){
        if(root == null){
            return;
        }
        Stack<TreeNode> stack=new Stack<>();
        TreeNode cur=root;
        while(cur != null || !stack.isEmpty()){
            while(cur != null) {
                stack.push(cur);
                System.out.print(cur.val + " ");
                cur=cur.left;
            }
            cur=stack.pop();
            cur=cur.right;
        }
    }

    public void inOrder(TreeNode root){
        if(root == null){
            return;
        }
        inOrder(root.left);
        System.out.print(root.val+" ");
        inOrder(root.right);
    }

    public void inOrderNor(TreeNode root){
        if(root == null){
            return;
        }
        Stack<TreeNode> stack=new Stack<>();
        TreeNode cur=root;
        while(cur != null || !stack.isEmpty()){
            while(cur != null){
                stack.push(cur);
                cur=cur.left;
            }
            cur=stack.pop();
            System.out.print(cur.val+" ");
            cur=cur.right;
        }
    }

    public static void main(String[] args) {

    }
}
